package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface setMealDishMapper {
    /**
     * 根据菜品Id查套餐
     *
     * @param dishIds
     * @return
     */
    List<Long> getSetMealIdsByDishIds(List<Long> dishIds);

    /**
     * 添加对应套餐的菜品
     *
     * @param setmealDishes
     */

    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id删除对应的菜品
     *
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id};")
    void deleteById(Long id);


    /**
     * 根据套餐Id查询菜品
     *
     * @param setmealId
     */
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> getDishBySetMealId(Long setmealId);

    /**
     * 根据套餐的id查套餐的里菜品的状态
     *
     * @param setMealId
     * @return
     */
    @Select("select d.* from setmeal_dish s right join dish d on s.dish_id = d.id where s.setmeal_id =#{setMealId}")
    List<Dish> getDishBySetmealId(Long setMealId);
}
